In [14]:
import math as m # math library
import numpy as np
import scipy as sp
import pandas as pd
import os
my_plotly_api_key = os.environ.get('MY_PLOTLY_API_KEY')
# setting up a key:
# in Terminal:
# export MY_PLOTLY_API_KEY = 'DHAHH3DSAD43D' (EXAMPLE)
import plotly
plotly.tools.set_credentials_file(username='agu3rra', api_key=my_plotly_api_key) # setting up credentials; Plotly is an online service.
import plotly.plotly as py # import graphics library
import plotly.graph_objs as go
from scipy import integrate
In [7]:
#Functions
In [20]:
def f1(x, y):
return (3 + x**2 - 2*y) # 3+x^2-2y
def bound_y(x):
return [-x,x]
def bound_x():
return [0.0,1.0]
In [21]:
integrate.nquad(f1, [bound_y, bound_x])
Out[21]:
In [22]:
integrate.dblquad(lambda x, y: 3 + x**2 - 2*y, 0, 1.0, lambda x: -x, lambda x: x)
Out[22]:
In [26]:
integrate.dblquad(lambda x, y: 3 + x**2 - 2*y, 1.0, 0.0, lambda x: x, lambda x: -x) # Wrong! As dy is the first inner most integral, the first lamdba call must be as the one below.
Out[26]:
In [28]:
integrate.dblquad(lambda y, x: 3 + x**2 - 2*y, 0.0, 1.0, lambda x: -x, lambda x: x)
Out[28]:
In [ ]: